﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;
using static DevExpress.XtraReports.Design.View.Office2003PaintHelper;
using System.Collections;
using DiaoPaiDaYin;
using DevExpress.XtraEditors.Popup;
using DevExpress.XtraGrid.Editors;
using DevExpress.Utils.Win;
using DevExpress.XtraLayout;
using DXApplicationTangche.UC.门店下单.DTO;
using DXApplicationTangche.DTO.坚山;
using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.service;

namespace DXApplicationTangche.UC.设计点
{
    public partial class UC工单信息 : UserControl
    {
        //private GridEditorCollection gridEditors;
        private String STYLEID;
        private String ORDERID;
        private List<工单内容> DTOs = new List<工单内容>();
        public UC工单信息(String STYLEID,String ORDERID)
        {
            this.STYLEID = STYLEID;
            this.ORDERID = ORDERID;
            InitializeComponent();
            //this.gridEditors = new GridEditorCollection();
            //this.gridControl工单信息.DataSource = this.gridEditors;
        }


        public class GridEditorItem
        {
            string fName;
            object fValue;
            RepositoryItem fRepositoryItem;

            public GridEditorItem(RepositoryItem fRepositoryItem, string fName, object fValue)
            {
                this.fRepositoryItem = fRepositoryItem;
                this.fName = fName;
                this.fValue = fValue;
            }
            public string Name { get { return this.fName; } }
            public object Value { get { return this.fValue; } set { this.fValue = value; } }
            public RepositoryItem RepositoryItem { get { return this.fRepositoryItem; } }
        }

        class GridEditorCollection : ArrayList
        {
            public GridEditorCollection()
            {
            }
            public new GridEditorItem this[int index] { get { return base[index] as GridEditorItem; } }
            public void Add(RepositoryItem fRepositoryItem, string fName, object fValue)
            {
                base.Add(new GridEditorItem(fRepositoryItem, fName, fValue));
            }
        }
        private void InitInplaceEditors()
        {
            foreach(DataRow dr in ItemService.Get工单信息设计点(ORDERID).Rows)
            {
                this.DTOs.Add(new 工单内容(dr));
            }
            this.DTOs.Add(new 工单内容(ItemService.Get工单信息面料(STYLEID)));
            this.gridControl工单信息.DataSource = this.DTOs;
        }
        //private void gridView工单信息_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
        //{

        //}
        public class 工单内容
        {
            public String ID { get; set; }//ID
            public String ITEM { get; set; }//项目
            public String VALUE { get; set; }//值
            public 工单内容(String id,String item,String value)
            {
                this.ID = id;
                this.ITEM = item;
                this.VALUE = value;
            }
            public 工单内容(DataRow dr)
            {
                this.ITEM = dr["ITEM"].ToString();
                this.VALUE = dr["VALUE"].ToString();
            }
            public 工单内容 buildWithDataRow(DataRow dr)
            {
                this.ITEM = dr["ITEM"].ToString();
                this.VALUE = dr["VALUE"].ToString();
                return this;
            }
        }
    }
}
